package com.blrs.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.core.page.TableDataInfo;
import com.blrs.domain.StageAchievement;
import com.blrs.service.process.IStageAchievementService;

@RestController
@RequestMapping("/process/achievement")
public class StageAchievementController extends BaseController {
    @Autowired
    private IStageAchievementService stageAchievementService;

    @GetMapping("/list")
    public TableDataInfo list(StageAchievement stageAchievement) {
        startPage();
        List<StageAchievement> list = stageAchievementService.selectStageAchievementList(stageAchievement);
        return getDataTable(list);
    }

    @GetMapping("/stage/{stageId}")
    public AjaxResult listByStageId(@PathVariable("templateId") String templateId,@PathVariable("stageId") String stageId) {
        return success(stageAchievementService.selectStageAchievementsByStageId(templateId,stageId));
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(stageAchievementService.selectStageAchievementById(id));
    }

    @PostMapping
    public AjaxResult add(@RequestBody StageAchievement stageAchievement) {
        return toAjax(stageAchievementService.insertStageAchievement(stageAchievement));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody StageAchievement stageAchievement) {
        return toAjax(stageAchievementService.updateStageAchievement(stageAchievement));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(stageAchievementService.deleteStageAchievementByIds(ids));
    }
} 